package com.clickpaas.workinghours.controller;

import com.clickpaas.workinghours.annotation.ControllerLog;
import com.clickpaas.workinghours.common.Response.ResponseResult;
import com.clickpaas.workinghours.entity.*;
import com.clickpaas.workinghours.service.ControllerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Api(description = "数据查询")
@RestController
@RequestMapping(value = "/query")
public class QueryController {
    @Resource
    ControllerService controllerService;

    @ApiOperation("查询工时填报数据")
    @PostMapping(value = "/timeCard")
    @ControllerLog
    public ResponseResult getTimeCardInfo(@ApiParam(value = "timeCardEntity")@RequestBody TimeCardEntity timeCardEntity){
        return controllerService.getTimeCardInfo(timeCardEntity);
    }

    @ApiOperation("查询项目列表")
    @PostMapping(value = "/project")
    @ControllerLog
    public ResponseResult getMaterialsInfo(@ApiParam(value = "projectEntity")@RequestBody ProjectEntity projectEntity){
        return controllerService.getProjectInfo(projectEntity);
    }

    @ApiOperation("查询商机数据")
    @PostMapping(value = "/opportunity")
    @ControllerLog
    public ResponseResult getOpportunityInfo(@ApiParam(value = "opportunityEntity")@RequestBody OpportunityEntity opportunityEntity){
        return controllerService.getOpportunityInfo(opportunityEntity);
    }

    @ApiOperation("查询市场活动数据")
    @PostMapping(value = "/campaign")
    @ControllerLog
    public ResponseResult getCampaignInfo(@ApiParam(value = "campaignEntity")@RequestBody CampaignEntity campaignEntity){
        return controllerService.getCampaignInfo(campaignEntity);
    }

    @ApiOperation("查询WBS数据")
    @PostMapping(value = "/wbs")
    @ControllerLog
    public ResponseResult getWbsInfo(@ApiParam(value = "projectEntity")@RequestBody ProjectEntity projectEntity){
        return controllerService.getWbsInfo(projectEntity);
    }

    @ApiOperation("查询用户名称")
    @PostMapping(value = "/userInfo")
    @ControllerLog
    public ResponseResult getUserInfo(HttpServletRequest httpServletRequest){
        return controllerService.getUserInfo(httpServletRequest);
    }

    @ApiOperation("查询工时填报主数据")
    @PostMapping(value = "/mainData")
    @ControllerLog
    public ResponseResult getMainData(HttpServletRequest httpServletRequest){
        return controllerService.getMainData(httpServletRequest);
    }

    @ApiOperation("查询当前日期对应的一周日期")
    @PostMapping(value = "/week")
    @ControllerLog
    public ResponseResult getWeek(WeekEntity weekEntity){
        return controllerService.getWeekend(weekEntity);
    }

}
